Xi-Language Reference: Array functions

    • carr (returns a byte array with the specified dimensions)
    • cincarr (returns a byte array with the specified dimensions)
    • cpxarr (returns a complex array with the specified dimensions)
    • cpxincarr (returns a complex array with the specified dimensions)
    • darr (returns a double array with the specified dimensions)
    • dincarr (returns a double array with the specified dimensions)
    • dist (computes square distance to the center of the array.)
    • farr (returns a float array with the specified dimensions)
    • fincarr (returns a float array with the specified dimensions)
    • histogram (computes a histogram )
    • iarr (returns a integer array with the specified dimensions)
    • iincarr (returns a integer array with the specified dimensions)
    • interval (Subdivid a interval into equidistant tiles)
    • interval2d (Subdivid a rectangle into tiles)
    • locate_max (looks for the location of a maximum.)
    • locate_min (looks for the location of a minimum.)
    • max (computes the maximum of an array.)
    • min (computes the maximum of an array.)
    • replicate (replicates the input array)
    • reshape (changes the shape of an array without its values numerically.)
    • sarr (returns a short integer array with the specified dimensions)
    • shift (shifts the input array)
    • sincarr (returns a short integer array with the specified dimensions)
    • size (gives some information about the input arrays)
    • sum (performs a summation over specified indices)
    • total (computes the total sum over the input array)

    carr (returns a byte array with the specified dimensions)

    Parameters

              carr ( dim1, dim2... )
    
              Types: dim1                   int
                     dim2...                int
    

    Return

              char[]  (byte array with the specified dimensions, allentries are  set to 0)
    

    Description

    The function carr returns a byte array of the dimensions specified by dim1, dim2, .... All entries of this array are equal to 0.

    Example

     >print(carr(3,4));
      <chrarr>
               0            0            0            0 
               0            0            0            0 
               0            0            0            0 
    

    See also

    cincarr

    cincarr (returns a byte array with the specified dimensions)

    Parameters

              cincarr ( dim1, dim2... )
    
              Types: dim1                   int
                     dim2...                int
    

    Return

              cincarr[]  (byte array with specified dimensions)
    

    Description

    The function cincarr returns a byte array with the dimensions specified by dim1, dim2, .... Each element of the array is set to its one-dimensional subscript.

    Example

     >print(cincarr(2,5));
     <chrarr>
    0 1 2 3 4 
    5 6 7 8 9 
    

    See also

    carr

    cpxarr (returns a complex array with the specified dimensions)

    Parameters

              cpxarr ( dim1, dim2... )
    
              Types: dim1                   int
                     dim2...                int
    

    Return

              complex[]  (complex array with the specified dimensions, all entries are equal (0.0, 0.0))
    

    Description

    The function cpxarr returns a complex array of the dimensions specified by dim1, dim2, .... All entries of this array are set to (0.0, 0.0).

    Example

     >print(cpxarr(5));
     <cpxarr>
     (           0,            0) (           0,            0) 
     (           0,            0) (           0,            0) 
     (           0,            0) 
    

    See also

    cpxincarr

    cpxincarr (returns a complex array with the specified dimensions)

    Parameters

              cpxincarr ( dim1, dim2... )
    
              Types: dim1                   int
                     dim2...                int
    

    Return

              complex[]  (complex array with specified dimensions)
    

    Description

    The function cpxincarr returns a complex array with the dimensions specified by dim1, dim2, .... Each element of the array is set to its one-dimensional subscript.

    Example

     >print(cpxincarr(5));
     <cpxarr>
     (           0,            0) (           1,            0) 
     (           2,            0) (           3,            0) 
     (           4,            0) 
    

    See also

    cpxarr

    darr (returns a double array with the specified dimensions)

    Parameters

              darr ( dim1, dim2... )
    
              Types: dim1                   int
                     dim2...                int
    

    Return

              double[]  (double array with the specified dimensions, allentries are  set to 0.0)
    

    Description

    The function darr returns a double array of the dimensions specified by dim1, dim2, .... All entries of this array are equal to 0.0.

    Example

     >print(darr(2,5));
      <dblarr>
               0            0            0            0            0 
               0            0            0            0            0 
    

    See also

    dincarr

    dincarr (returns a double array with the specified dimensions)

    Parameters

              dincarr ( dim1, dim2... )
    
              Types: dim1                   int
                     dim2...                int
    

    Return

              double[]  (double array with specified dimensions)
    

    Description

    The function dincarr returns a double array with the dimensions specified by dim1, dim2, .... Each element of the array is set to its one-dimensional subscript.

    Example

     >print(dincarr(2,5));
     <dblarr>
               0            1            2            3            4 
               5            6            7            8            9 
    

    See also

    darr

    dist (computes square distance to the center of the array.)

    Parameters

              dist ( dim1, dim2... )
    
              Types: dim1                   int
                     dim2...                int
    

    Return

              double[]
    

    Description

    The function dist computes a multidimensionale array. The dimensions are given by the parameter dim1, dim2,... Each entry of the return array corresponds to the square distance to the center of the array.

    Example

     >print(dist(5));
     <dblarr>
               4            1            0            1            4
     >print(dist(3,3));
     <dblarr>
                2            1            2 
                1            0            1 
                2            1            2 
    

    farr (returns a float array with the specified dimensions)

    Parameters

              farr ( dim1, dim2... )
    
              Types: dim1                   int
                     dim2...                int
    

    Return

              float[]  (float array with the specified dimensions, allentries are  set to 0.0)
    

    Description

    The function farr returns a float array of the dimensions specified by dim1, dim2, .... All entries of this array are equal to 0.0.

    Example

     >print(farr(2,4));
      <fltarr>
               0            0            0            0 
               0            0            0            0 
    

    See also

    fincarr

    fincarr (returns a float array with the specified dimensions)

    Parameters

              fincarr ( dim1, dim2... )
    
              Types: dim1                   int
                     dim2...                int
    

    Return

              float[]  (float array with specified dimensions)
    

    Description

    The function fincarr returns a float array with the dimensions specified by dim1, dim2, .... Each element of the array is set to its one-dimensional subscript.

    Example

     >print(fincarr(2,5));
     <fltarr>
               0            1            2            3            4 
               5            6            7            8            9 
    

    See also

    farr

    histogram (computes a histogram )

    Parameters

              histogram ( array, binsize )
    
              Types: array                  double[]/float[]/integer[]/short[]/char[]
                     binsize                double
    

    Return

              [int[],double[]]  (contains the density function of an array)
    

    Description

    The function histogram computes the density function of an array. The parameter \binsize determines the size of the bins. The first return array contains the density array the second return array gives the locations of the bins.

    Example

     >a={ 1, 1.3, 2, 1.6, 3, 4, 2.5, 1.4, 1.8, 2.3 };
     >[h, x]=histogram(a,\binsize=0.5);
     >print(h);
     <intarr>
     3 2 2 1 1 0 1
     >print(x);
     <dblarr>
             1.25         1.75         2.25         2.75         3.25         3.75
             4.25
    

    See also

    hist_equal

    iarr (returns a integer array with the specified dimensions)

    Parameters

              iarr ( dim1, dim2... )
    
              Types: dim1                   int
                     dim2...                int
    

    Return

              int[]  (integer array with the specified dimensions, allentries are  set to 0)
    

    Description

    The function iarr returns a integer array of the dimensions specified by dim1, dim2, .... All entries of this array are equal to 0.

    Example

     >print(iarr(3,4));
      <intarr>
               0            0            0            0 
               0            0            0            0 
               0            0            0            0 
    

    See also

    iincarr

    iincarr (returns a integer array with the specified dimensions)

    Parameters

              iincarr ( dim1, dim2... )
    
              Types: dim1                   int
                     dim2...                int
    

    Return

              integer[]  (integer array with specified dimensions)
    

    Description

    The function iincarr returns a integer array with the dimensions specified by dim1, dim2, .... Each element of the array is set to its one-dimensional subscript.

    Example

     >print(iincarr(2,5));
     <intarr>
               0            1            2            3            4 
               5            6            7            8            9 
    

    See also

    iarr

    interval (Subdivid a interval into equidistant tiles)

    Parameters

              interval ( x0, xn, n = 100 )
    
              Types: x0                     double
                     xn                     double
                     n                      int
    

    Return

              double[]  (contains the x-values)
    

    Description

    interval simply subdivides the interval [x0,xn] into n equistant tiles. It returns an array with n+1 elements, such that the first element is x0 and the last is xn.

    Example

     (  1)>x=interval(0,1,10);
     Function interval defined
     (  2)>print(x)
     <dblarr> 
                0          0.1          0.2          0.3          0.4          0.5 
              0.6          0.7          0.8          0.9            1 
    

    See also

    interval2d

    interval2d (Subdivid a rectangle into tiles)

    Parameters

              interval2d ( x0, y0, xn, yn, nx = 100, ny = 100 )
    
              Types: x0                     double
                     y0                     double
                     xn                     double
                     yn                     double
                     nx                     int
                     ny                     int
    

    Return

              [double[],double[]]  (contains the x- and y-values)
    

    Description

    interval2d generates a tiling of a rectangular domain of the plane. This is especially useful for evaluation of two dimensional functions. The rectangle is defined by the two corners (x0,y0) and (xn,yn). interval2d will return two (nx+1)x(ny+1) array containing the x- resp. y-coordinates, such that x[.,0]=x0, x[.,nx]=xn , y[0,.]=y0 and y[ny,.]=yn.

    Example

     (  1)>[x,y]=interval2d(0,0,1,1,2,2);
     Function interval2d defined
     (  2)>print(x,y)
     <dblarr>
                0          0.5            1 
                0          0.5            1 
                0          0.5            1 
     <dblarr>
                0            0            0 
              0.5          0.5          0.5 
                1            1            1 
    

    See also

    interval2d

    locate_max (looks for the location of a maximum.)

    Parameters

              locate_max ( array )
    
              Types: array                  complex[]/double[]/float[]/integer[]/short[]/char[]
    

    Return

              int[]  (contains the indices of the maximum)
    

    Description

    The function locate_max computes the location of the maximum of the input array. It returns the indices of the maximum by a integer array. If the maximum isn't unique the return array contains the indices of each maximum column by column.

    Example

    >a = { { 9,3,4 }, { 9,6,7}, {8, 9,10} };
    >print(a);
    <intarr>
     9  3  4
     9  6  7
     8  9 10
    >print(locate_max(a));
    <intarr>
    <intarr>
    0 1 2
    0 0 1
    

    See also

    max, min, locate_min

    locate_min (looks for the location of a minimum.)

    Parameters

              locate_min ( array )
    
              Types: array                  complex[]/double[]/float[]/integer[]/short[]/char[]
    

    Return

              int[]  (contains the indices of the minimum)
    

    Description

    The function locate_min computes the location of the minimum of the input array. It returns the indices of the minimum by a integer array. If the minimum isn't unique the return array contains the indices of each minimum column by column.

    Example

    >a = { {-9,3,4 }, {-9,6,7}, {8,-9,10} };
    >print(a);
    <intarr>
    -9  3  4
    -9  6  7
     8 -9 10
    >print(locate_min(a));
    <intarr>
    <intarr>
    0 1 2
    0 0 1
    

    See also

    min, max, locate_max

    max (computes the maximum of an array.)

    Parameters

              max ( array )
    
              Types: array                  complex[]/double[]/float[]/integer[]/short[]/char[]
    

    Return

              Any  (the maximum of the array, same type as the input \e\array\e\)
    

    Description

    The function max returns the maximum of the input array. Its of the same type as the input array

    Example

    >a = { {9, 3, 4 }, {9,6,7}, {8, 9,10} };
    >print(max(a));
    <int> 10
    

    See also

    locate_max, min, locate_min

    min (computes the maximum of an array.)

    Parameters

              min ( array )
    
              Types: array                  complex[]/double[]/float[]/integer[]/short[]/char[]
    

    Return

              Any  (the minimum of the array, same type as the input \e\array\e\)
    

    Description

    The function min returns the minimum of the input array. Its of the same type as the input array

    Example

    >a = { {9, 3, 4 }, {9,6,7}, {8, 9,10} };
    >print(min(a));
    <int> 3
    

    See also

    locate_min, max, locate_max

    replicate (replicates the input array)

    Parameters

              replicate ( array, n )
    
              Types: array                  complex[]/double[]/float[]/integer[]/short[]/char[]
                     n                      int
    

    Return

              Any[]  (replicated input array)
    

    Description

    The function replicate replicates an array with m dimensions n times to get a (m+1) dimensional array.

    Example

     >a=cincarr(5);
     >print(replicate(a,3));
     <chrarr>
     0 1 2 3 4 
     0 1 2 3 4 
     0 1 2 3 4 
     >b=cincarr(2,5);
     >print(replicate(b,3));
     <chrarr>
     0 1 2 3 4 
     5 6 7 8 9 
    
     0 1 2 3 4 
     5 6 7 8 9 
    
     0 1 2 3 4 
     5 6 7 8 9 
    

    See also

    reshape

    reshape (changes the shape of an array without its values numerically.)

    Parameters

              reshape ( array )
    
              Types: array                  complex[]/double[]/float[]/integer[]/short[]/char[]
    

    Return

              Any[]  (array with the specified dimensions, same type as input array)
    

    Description

    The function reshape returns a array of the dimensions specified by dim1, dim2, .... It s a copy of array only the dimensions of array are changed. Its values remain unchanged.

    Example

    >a=cincarr(4,5);
    >print(a);
    <chrarr>
     0  1  2  3  4 
     5  6  7  8  9 
    10 11 12 13 14 
    15 16 17 18 19 
    >print(rehape(a,2,10));
    <chrarr>
     0  1  2  3  4 
     5  6  7  8  9 
    10 11 12 13 14 
    15 16 17 18 19 
    

    sarr (returns a short integer array with the specified dimensions)

    Parameters

              sarr ( dim1, dim2... )
    
              Types: dim1                   int
                     dim2...                int
    

    Return

              short[]  (short integer array with the specified dimensions, allentries are  set to 0)
    

    Description

    The function sarr returns a short integer array of the dimensions specified by dim1, dim2, .... All entries of this array are equal to 0.

    Example

     >print(sarr(3,4));
      <shtarr>
               0            0            0            0 
               0            0            0            0 
               0            0            0            0 
    

    See also

    sincarr

    shift (shifts the input array)

    Parameters

              shift ( array, n1, n2... )
    
              Types: array                  complex[]/double[]/float[]/integer[]/short[]/char[]
                     n1                     int
                     n2...                  int
    

    Return

              Any[]  (shifted array of the same type as the input \e\array\e\)
    

    Description

    The function shift performs a circular shift on the entries of array by n1, n2, .. numbers of elements. Hereby the parameter \n1\ corresponds to the first dimension of the input array, n2 the the second dimension and so on.

    Example

     >a=cincarr(2,5);
     >print(a, shift(a,0,1));
     <chrarr>
     0 1 2 3 4 
     5 6 7 8 9 
     <chrarr>
     1 2 3 4 0 
     6 7 8 9 5 
    

    sincarr (returns a short integer array with the specified dimensions)

    Parameters

              sincarr ( dim1, dim2... )
    
              Types: dim1                   int
                     dim2...                int
    

    Return

              short[]  (short integer array with specified dimensions)
    

    Description

    The function sincarr returns a short integer array with the dimensions specified by dim1, dim2, .... Each element of the array is set to its one-dimensional subscript.

    Example

     >print(sincarr(2,5));
     <shtarr>
               0            1            2            3            4 
               5            6            7            8            9 
    

    See also

    sarr

    size (gives some information about the input arrays)

    Parameters

              size ( array )
    
              Types: array                  complex[]/double[]/float[]/integer[]/short[]/char[]
    

    Return

              intarr[]  (contains information about the \e\array\e\.)
    

    Description

    The function size returns a integer array containing information about the input array. The first entry of the result is the type code. (0 = complex, 1 = double, 2 = float, 3 = integer, 4 = short, 5 = char). The second entry gives the number of dimensions of the array and the next entry is the total number of elements of the array. The following entries are equal to the sizes of the corresponding dimensions.

    Example

     >print(size(carr(5)));
     <intarr>
     5 1 5 5
     >print(size(cpxarr(5,3,6)));
     <intarr>
     0  3 90  5  3  6 
    

    See also

    reshape

    sum (performs a summation over specified indices)

    Parameters

              sum ( array, index1, index2... )
    
              Types: array                  complex[]/double[]/float[]/integer[]/short[]/char[]
                     index1                 int
                     index2...              int
    

    Return

              Any[]  (array of the same type as the input array.)
    

    Description

    The function sum performs a summation over some indices of array specified by index1, index2, ....

    Example

     >a=cincarr(2,5);
     >print(a);
     <chrarr>
     0 1 2 3 4 
     5 6 7 8 9
     >print(sum(a,0));
      <chrarr>
      5  7  9 11 13
     >print(sum(a,1));
     <chrarr>
     10 35 
     >print(sum(a,0,1));
     <chrarr>
     45 
    

    See also

    total

    total (computes the total sum over the input array)

    Parameters

              total ( array )
    
              Types: array                  complex[]/double[]/float[]/integer[]/short[]/char[]
    

    Return

              Any  (the total sum over the array)
    

    Description

    The function total performs the total sum over an array.

    Example

    >a = { {9, 3, 4 }, {9,6,7}, {8, 9,10} };
    >print(total(a));
    <int> 65
    >print(sum(a), 0, 1);
    <intarr>
    65
    

    See also

    sum
    © 1995 by Bodo Junglas, Klaus Spanderen and Fabian Weis
    - Last revised: Wed Jun 19 16:58:32 1996